package model;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

/**
 * Source entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "source", catalog = "clode")
public class Source implements java.io.Serializable {

	// Fields

	private Integer id;
	private Category category;
	private User user;
	private String name;
	private String language;
	private Date lastModifiedDate;
	private Date createDate;
	private Set<Tag> tags = new HashSet<Tag>(0);

	// Constructors

	/** default constructor */
	public Source() {
	}

	/** minimal constructor */
	public Source(Category category, User user, String name) {
		this.category = category;
		this.user = user;
		this.name = name;
	}

	/** full constructor */
	public Source(Category category, User user, String name, String language,
			Date lastModifiedDate, Date createDate, Set<Tag> tags) {
		this.category = category;
		this.user = user;
		this.name = name;
		this.language = language;
		this.lastModifiedDate = lastModifiedDate;
		this.createDate = createDate;
		this.tags = tags;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "categoryId", nullable = false)
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userId", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "name", nullable = false, length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "language", length = 50)
	public String getLanguage() {
		return this.language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "lastModifiedDate", length = 10)
	public Date getLastModifiedDate() {
		return this.lastModifiedDate;
	}

	public void setLastModifiedDate(Date lastModifiedDate) {
		this.lastModifiedDate = lastModifiedDate;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "createDate", length = 10)
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "sources")
	public Set<Tag> getTags() {
		return this.tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

}